package com.quzitech.efest.fragments;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.quzitech.efest.R;
import com.quzitech.efest.activitys.main.MainActivity;
import com.quzitech.efest.utils.Myutil;

public class FragmentGuide extends Fragment {
	private View mMainView;
	public ImageView iv_fragment;
	private int resid = 0;

	public FragmentGuide(int resid) {
		this.resid = resid;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		// LayoutInflater inflater = getActivity().getLayoutInflater();

	}

	public void setFragmentBackground(Drawable drawable) {
		iv_fragment.setBackgroundDrawable(drawable);
	}

	public void setFragmentBackground(int resid) {
		iv_fragment.setBackgroundResource(resid);
	}

	public void setbgResId(int resid) {
		this.resid = resid;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// LayoutInflater inflater = getActivity().getLayoutInflater();
		// Log.v("oncreate", "i am in the oncreate------------>");
		mMainView = inflater.inflate(R.layout.fragment_guide, null);

		ViewGroup p = (ViewGroup) mMainView.getParent();
		if (p != null) {
			p.removeAllViewsInLayout();
		}
		iv_fragment = (ImageView) mMainView.findViewById(R.id.iv_guide_bg);
		if (resid != 0) {
			iv_fragment.setBackgroundResource(resid);
		}
		iv_fragment.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (getActivity() != null) {
					startActivity(new Intent(getActivity(), MainActivity.class));
				}

			}
		});

		return mMainView;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onPause() {
		super.onPause();
	}

	@Override
	public void onResume() {
		super.onResume();
	}

	@Override
	public void onStart() {
		super.onStart();
	}

	@Override
	public void onStop() {
		super.onStop();
	}

}
